//引入封装好的菜单列表接口
import {menuList} from '../../../util/request/api'
//封装菜单管理的状态管理
const state = {
    //菜单列表
    menulist:[]
}

const getters ={
    getMenuList(state){
        return state.menulist
    }
}

const mutations = {
    REQ_MENULIST(state,payload){
        state.menulist = payload
    }
}

const actions ={
    //封装一个行动用于修改菜单列表
    getMenuAction({commit}){
        menuList({
            istree:true
        })
        .then(res=>{
            if(res.code==200){
                commit('REQ_MENULIST',res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}